import {reactive,onMounted,onUnmounted} from 'vue'

export function useMousePosition(){
    const position = reactive({
        x:0,
        y:0,
    })
    const handleMouseMove = (e)=>{
        position.x = e.clientX;
        position.y = e.clientY
    }
    onMounted(()=>{
        window.addEventListener('mousemove',handleMouseMove)
    })
    onUnmounted(()=>{
        window.removeEventListener('mousemove',handleMouseMove)
    })
    return position
}